<template>
  <el-dialog
    title="审核不通过"
    :visible.sync="noPassDialogData.isShow"
    width="30%"
    top="35vh"
    @close="closeNoPassDialog"
  >
    <div>
      <el-input
        v-model="noPassReason"
        type="textarea"
        :rows="10"
        placeholder="请输入"
        resize="none"
        class="textarea"
      ></el-input>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button type="success" plain @click="noPassDialogData.isShow = false"
        >关 闭</el-button
      >
      <el-button type="success" class="submitPass" @click="confirm"
        >提 交</el-button
      >
    </span>
  </el-dialog>
</template>
<script>
import { failRequestAPI } from '@/api/operate/active'
export default {
  props: ['noPassDialogData'],
  data() {
    return {
      noPassReason: '', // 审核不通过原因
      id: ''
    }
  },
  mounted() {
    this.id = this.noPassDialogData.params.id
  },
  methods: {
    // 确认审核不通过
    confirm() {
      if (this.noPassReason.length > 200) {
        this.$alert('不通过原因不可以超过200字', '系统提示', {
          confirmButtonText: '确定',
          type: 'error'
        })
        return
      }
      let params = {
        remark: this.noPassReason,
        isQueryString: true
      }
      failRequestAPI(
        this.id,
        params,
        (response) => {
          this.$message({
            message: '操作成功',
            type: 'success'
          })
          this.noPassDialogData.isShow = false
          this.$emit('refresh')
        },
        (response) => {
          this.$message({
            message: response.message,
            type: 'warning'
          })
        }
      )
    },
    // 关闭对话框回调
    closeNoPassDialog() {
      this.noPassReason = ''
    }
  }
}
</script>
<style lang="less" scoped>
.textarea {
  margin-bottom: 50px;
}
</style>
